import { queryAccountCenterTeam, queryFakeList } from '@/services/api';

export default {
  namespace: 'AccountCenterModel',

  state: {
    // 团队信息
    team: [],
    // 文章-应用-项目 数据
    listData: [],
  },

  effects: {
    *fetchTeam(_, { call, put }) {
      const response = yield call(queryAccountCenterTeam);
      yield put({ type: 'saveTeam', payload: Array.isArray(response) ? response : [] });
    },
    *fetchListData({ payload }, { call, put }) {
      const response = yield call(queryFakeList, payload);
      yield put({ type: 'saveListData', payload: Array.isArray(response) ? response : [] });
    },
  },

  reducers: {
    saveTeam(state, action) {
      return { ...state, team: action.payload };
    },
    saveListData(state, action) {
      return { ...state, listData: action.payload };
    },
  },
};
